const {
	defineConfig
} = require("@vue/cli-service");
const path = require("path");
const webpack = require("webpack");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");

function resolve(dir) {
	return path.join(__dirname, dir);
}
module.exports = defineConfig({
	configureWebpack: {
		plugins: [new NodePolyfillPlugin({})],
	},
	transpileDependencies: true,
	lintOnSave: false, //关闭语法检查 esline
	devServer: {
		port: 8037,
		historyApiFallback: true,
		// 代理
		proxy: {
			// 哪些要代理，哪些不要代理
			'^/api': {
				target: 'http://localhost:9000', // 代理到哪里去
				changeOrigin: true, // 支持跨域
				pathRewrite: { // 重写路径 
					'/api': '' //将‘/api’路径修改为''
				}
			},
		},
	},
	chainWebpack(config) {
		// set svg-sprite-loader
		config.module.rule("svg").exclude.add(resolve("src/icons")).end();
		config.module
			.rule("icons")
			.test(/\.svg$/)
			.include.add(resolve("src/icons"))
			.end()
			.use("svg-sprite-loader")
			.loader("svg-sprite-loader")
			.options({
				symbolId: "icon-[name]",
			})
			.end();
	},
});